@extends('layouts.default') @section('main')
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <link rel="stylesheet" href="/css/uniform.css" />
    <link rel="stylesheet" href="/css/select2.css" />
    <style> #search li{float:right; list-style: none;}</style>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a>
                <a href="#" class="current">项目评审</a> </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    <table>
                        <tr>
                            <form action="{{url('allproject/search')}}" method="post">
                                <th>
                                    <label >项目名称 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject" value="" placeholder="项目名称" />
                                    </div>
                                </th>
                                <th>
                                    <label >是否已评审 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <select  name="audit" class="span11" >
                                            <option value="">请选择</option>
                                            <option value="1">是</option>
                                            <option value="0">否</option>
                                        </select>
                                    </div>
                                </th>
                                <th>
                                    <label >指派人员 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <select  name="admin" class="span11" >
                                            <option value="">请选择</option>
                                            @foreach($admins as $k)
                                                <option value="{{$k->id}}">{{$k->nickname}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </th>
                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-info">查询</button>
                                    </div>
                                </th>
                            </form>
                            <th>
                                <label >指派给 :</label>
                            </th>
                            <th>
                                <div class="controls">
                                    <select  id="admin" name="source" class="span11" >
                                        <option value="">请选择</option>
                                        @foreach($admins as $k)
                                            <option value="{{$k->id}}">{{$k->nickname}}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </th>
                            <th>
                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                <div class="controls">
                                    <button type="button" id="assign" class="btn btn-info">批量分配</button>
                                </div>
                            </th>
                        </tr>
                    </table>
                    <div class="widget-box">
                        <div class="widget-title">
                            <span class="icon">
                                <input type="checkbox" id="title-checkbox" name="title-checkbox" />
                            </span>
                            <h5>完整度大于85%的项目列表</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <table class="table table-bordered table-striped with-check" id="table">
                                <thead>
                                <tr>
                                    <th><i class="icon-resize-vertical"></i></th>
                                    <th>项目名称</th>
                                    <th>创建时间</th>
                                    <th>发布时间</th>
                                    <th>更新时间</th>
                                    <th>所在地区</th>
                                    <th>发布者</th>
                                    <th>指派审核人</th>
                                    <th>详情</th>
                                    <th>完整度</th>
                                    <th>状态</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($lists as $list)
                                    <tr>
                                        <td><input type="checkbox" value="{{$list->id}}" /></td>
                                        <td title="{{$list->subject}}">{{cut_str($list->subject,12,'...')}}</td>
                                        <td>{{date('Y-m-d', strtotime($list->created_at->toDateTimeString()))}}</td>
                                        <td>{{date('Y-m-d', $list->pubdate)}}</td>
                                        <td>{{date('Y-m-d', strtotime($list->updated_at->toDateTimeString()))}}</td>
                                        <td>@if($list->zone){{$list->zone->name}}@endif</td>
                                        <td>@if($list->user){{$list->user->nickname}}@endif</td>
                                        <td>@if($list->admin){{$list->admin->nickname}}@endif</td>
                                        <td>点击查看</td>
                                        <td>{{$list->progress}}</td>
                                        <td>@if($list->status == 1)<i class="icon-ok"></i>@elseif($list->status == 0)<i class="icon-question"></i>>@elseif($list->status == -1)<i class="icon-remove"></i>@endif</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <?php echo $lists->appends(['subject' => $subject,'audit' => $audit,'admin' => $admin])->render();?>
                </div>
            </div>
        </div>
    </div>
    <script src="/js/matrix.tables.js"></script>
    <script>
        function allchk(){
            var chknum = $("#table :checkbox").size();//选项总个数
            var chk = 0;
            $("#table :checkbox").each(function () {
                if($(this).prop("checked")==true){
                    chk++;
                }
            });
            if(chknum==chk){
                $("#title-checkbox").prop("checked",true);
            }else{
                $("#title-checkbox").prop("checked",false);
            }
        }

        $("#title-checkbox").click(function(){
            if(this.checked){
                $("#table :checkbox").prop("checked", true);
            }else{
                $("#table :checkbox").prop("checked", false);
            }
        });

        $("#table :checkbox").click(function(){
            allchk();
        });

        $("#assign").click(function(){
            var valArr = new Array();

            $("#table :checkbox").each(function(i){
                if($(this).prop('checked')==true){
                    valArr[i] = $(this).val();
                }

            });
            var vals = valArr.join(',');
            var valAdmin = ($('#admin').val());
            ajaxRequest({ project: vals, admin: valAdmin },"{{url('allproject/assign')}}",function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>
@stop
